home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 June / PCpro_2006_06.ISO / files / freeware / openvip.exe / {app} / fileinfo.py < prev    next >
Encoding:
Python Source  |  2003-05-24  |  2.0 KB  |  65 lines

  1. #!/usr/bin/env python
  2.  
  3. #
  4. # This file is part of OpenVIP (http://openvip.sourceforge.net)
  5. #
  6. # Copyright (C) 2002-2003
  7. # Michal Dvorak, Jiri Sedlar, Antonin Slavik, Vaclav Slavik, Jozef Smizansky
  8. #
  9. # This program is licensed under GNU General Public License version 2;
  10. # see file COPYING in the top level directory for details.
  11. #
  12. # $Id: fileinfo.py,v 1.4 2003/05/24 22:17:22 vaclavslavik Exp $
  13. #
  14.  
  15. #
  16. # Display file's metadata information.
  17. # Implemented using OpenVIP input plugins.
  18. #
  19.  
  20. import openvip, sys
  21.  
  22. if len(sys.argv) < 2:
  23.     sys.stderr.write("""
  24. Usage: %s filename [filename ...]
  25.  
  26.        where 'filename' may be either name of audio or video file or name of
  27.        OpenVIP network format file (*.openvip, *.xml)
  28. """ % sys.argv[0])
  29.  
  30.  
  31. def printFileInfo(lib, filename):
  32.     splitted = filename.split(':')
  33.     if len(splitted) == 2 and (splitted[0].endswith('.xml') or
  34.                                  splitted[0].endswith('.openvip')):
  35.         print 'OpenVIP network file: %s' % filename
  36.         task = lib.load_network_file(splitted[0])
  37.         i = lib.get_task_file_info(task, splitted[1])
  38.     else:
  39.         print 'Multimedia file: %s' % filename
  40.         i = lib.get_file_info(filename)
  41.     
  42.     if i == None:
  43.         sys.stderr.write('Error when reading %s\n' % filename)
  44.         return
  45.     for v in i.video_streams:
  46.         seconds = float(v.length)/v.fps
  47.         print '    video stream "%s"' % v.name
  48.         print '        width:        %i' % v.width
  49.         print '        height:       %i' % v.height
  50.         print '        fps:          %f' % v.fps
  51.         print '        aspect ratio: %f' % v.aspect
  52.         print '        length:       %i frames (%.1f sec)' % (v.length, seconds)
  53.     for a in i.audio_streams:
  54.         seconds = float(a.length)/a.sample_rate
  55.         print '    audio stream "%s"' % a.name
  56.         print '        sample rate:  %i Hz' % a.sample_rate
  57.         print '        channels:     %i' % a.channels
  58.         print '        length:       %i samples (%.1f sec)' % (a.length, seconds)
  59.  
  60.  
  61. lib = openvip.Library()
  62.  
  63. for f in sys.argv[1:]:
  64.     printFileInfo(lib, f)
  65.